


//
//  StatusForwardCell.m
//  kuangjia
//
//  Created by 张帅 on 15/10/4.
//  Copyright © 2015年 ZhangShuai. All rights reserved.
//

#import "StatusForwardCell.h"
#import "UILabel+Contenlable.h"
@interface StatusForwardCell ()

@property(nonatomic,strong) UILabel *forwardLabel;

@property(nonatomic,strong) UIButton *backButton;
@end
@implementation StatusForwardCell


-(void)setStatusViewModel:(StatusViewModel *)statusViewModel{
    [super setStatusViewModel:statusViewModel];
    
   
    self.forwardLabel.text =  statusViewModel.forwardText;
 
    CGFloat offset = self.statusViewModel.thumbnailURLs.count ==0 ? 0:HMStatusPictureItemMargin;
    [self.pictureView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.forwardLabel.mas_bottom).offset(offset);
    }];
//    self.pictureViewTopCons.equalTo(self.forwardLabel.mas_bottom).offset(offset);
}

//设置UI

-(void)setupUI{
    
    
    [super setupUI];
    
           // 添加控
    self.backButton.translatesAutoresizingMaskIntoConstraints =NO;
    self.forwardLabel.translatesAutoresizingMaskIntoConstraints =NO;
    
//    [self.contentView addSubview:self.backButton];
//    
//    [self.contentView addSubview:self.forwardLabel];
    [self.contentView insertSubview:self.backButton belowSubview: self.pictureView];
    [self.contentView insertSubview:self.forwardLabel aboveSubview:self.backButton];
    
    
    //MARK:   // 设置布局
    // 1> 背景按钮
    
    //MARK:  backButton;
    
       // 相对 contenlable
    [self.backButton  mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentLabel.mas_left).offset(-HMStatusCellMargin);
        make.top.equalTo(self.contentLabel.mas_bottom).offset(HMStatusCellMargin);
        make.right.equalTo(self.bottomView.mas_right);
        make.bottom.equalTo(self.bottomView.mas_top);
    }];

    
        // 2> 转发文字
         //在backButton 里面
    [self.forwardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentLabel.mas_left);
        make.top.equalTo(self.contentLabel.mas_bottom).offset(HMStatusCellMargin);
        
    }];
    // forwardLabel 的左上部约束
    
    //pictureView
    
    
  [self.pictureView mas_makeConstraints:^(MASConstraintMaker *make) {
      make.left.equalTo(self.forwardLabel.mas_left);
      self.pictureViewTopCons =make.top.equalTo(self.forwardLabel.mas_bottom).offset(HMStatusCellMargin);
  
      self.pictureViewHeightCons=make.height.equalTo(@(HMStatusPictureMaxWidth));
      self.pictureViewWidthCons=make.width.equalTo(@(HMStatusPictureMaxWidth));
      
    
  }];
    

}



-(UIButton *)backButton{
    if (_backButton==nil) {
        
        _backButton=[UIButton new];
        
        [_backButton setBackgroundColor:[UIColor colorWithWhite:0.3 alpha:0.4]];
       
    }

    return _backButton;
}
-(UILabel *)forwardLabel{

    if (_forwardLabel==nil) {
        
     _forwardLabel=[[UILabel alloc] initWithTitle:@"转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微" color:[UIColor darkGrayColor] sizeFont:15 layoutWidth:([UIScreen mainScreen].bounds.size.width -2*HMStatusCellMargin)];

            }
    return _forwardLabel;
}
@end
